package com.example.demo.web;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

@Slf4j
@Configuration
public class AsyncServiceImpl   implements AsyncConfigurer {
    @Override
    public Executor getAsyncExecutor() {
        ThreadPoolTaskExecutor poolExecutor = new ThreadPoolTaskExecutor();
        //核心线程数
        poolExecutor.setCorePoolSize(10);
        //线程池最大线程数
        poolExecutor.setMaxPoolSize(30);
        //线程队列最大线程数
        poolExecutor.setQueueCapacity(2000);
        //初始化
        poolExecutor.initialize();
        return poolExecutor;
    }


}
